package pkgjeudestrategie;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

/**
 *
 * @author Marvens
 */
public class MenuTitre extends JPanel {

    private Fenetre fenetre;
    private JButton btnNouvellePartie;
    private JButton btnChargerPartie;
    private JButton btnOption;
    private JButton btnQuitter;
    private JButton btnGuide;
    JPanel pnl1 = new JPanel();
    JPanel pnlBtn = new JPanel();
    ImageIcon img = new ImageIcon("imagespi/imgMenu.jpg");
    ImageIcon imgBtn = new ImageIcon("imagespi/imgBtnMenu.jpg");
    ArrayList<JButton> listeBtn = new ArrayList();
    boolean newGame;

    public MenuTitre(Fenetre fenetre) {

        this.fenetre = fenetre;

        //this.setLocation((Fenetre.tailleX/2)-250,(Fenetre.tailleY/2)-250);
        setLocation(0, 0);
        setLayout(null);

        pnl1.setLayout(null);
        pnlBtn.setBounds(40, 300, 320, 400);
        this.actionBouton();
    }

    private void actionBouton() {
        btnNouvellePartie = new JButton("Nouvelle Partie");
        btnChargerPartie = new JButton("Charger Partie");
        btnOption = new JButton("Options");
        btnQuitter = new JButton("Quitter");
        btnGuide = new JButton("Guide");

        listeBtn.add(btnNouvellePartie);
        listeBtn.add(btnChargerPartie);
        listeBtn.add(btnOption);
        listeBtn.add(btnGuide);
        listeBtn.add(btnQuitter);

        btnNouvellePartie.setBounds(40, 300, 320, 50);
        btnChargerPartie.setBounds(40, 380, 320, 50);
        btnOption.setBounds(40, 460, 320, 50);
        btnGuide.setBounds(40, 540, 320, 50);
        btnQuitter.setBounds(40, 620, 320, 50);

        for (JButton btnMenu : listeBtn) {
            
            btnMenu.setForeground(Color.BLACK);
            
            btnMenu.setHorizontalTextPosition(SwingConstants.CENTER);
            btnMenu.setIcon(imgBtn);

            add(btnMenu);
        }

        JLabel lblTitre = new JLabel("JEU DE STRATÉGIE", JLabel.CENTER);
        lblTitre.setFont(lblTitre.getFont().deriveFont(30.0f));
        lblTitre.setBounds(50, 100, 300, 100);
        lblTitre.setForeground(Color.WHITE);
        add(lblTitre);

        btnChargerPartie.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                newGame = false;
                fenetre.nouveauJeu(newGame);
            }
        });
        this.btnNouvellePartie.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                newGame = true;
                fenetre.nouveauJeu(newGame);
            }
        });
        this.btnOption.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
            }
        });
        this.btnQuitter.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                System.exit(0);
            }
        });
        this.btnGuide.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
            }
        });

    }

    @Override
    protected void paintComponent(Graphics g) {

        img.paintIcon(this, g, 0, 0);

    }
}
